<?php
namespace app\common\model;

use think\Model;
use think\Db;
class UserSpecialty extends Model
{
    // 指定表名,不含前缀
    protected $name = 'userSpecialty';
    
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    public function getList($admin_reg){
      
		$parent_id = Db::name('plaform')->where(['admin_reg'=>$_SESSION["think"]["reg"]])->field('parentid')->find();
		if($parent_id['parentid']){

			$adreg = Db::name('plaform')->where(['id'=>$parent_id['parentid'],'status'=>1])->field('admin_reg')->find();
			$rg = empty($adreg['admin_reg']) ? [$admin_reg] : [$admin_reg,$adreg['admin_reg']];
			$arr=$this->field('id,name,pid')->where(['status'=>1,'isdelete'=>0,'admin_reg'=>['in',$rg]])->select();
			
		} else {
			  $arr=$this->field('id,name,pid')->where('status=1 and isdelete=0 and admin_reg="'.$admin_reg.'"')->select();
			
		}
	
		//['status'=>1,'isdelete'=>0,'admin_reg'=>['in',$admin_reg]]
        return $arr;
    }
}
